using System;
using System.IO;

namespace wicpowerTcpTool
{
    public static class Logger
    {
        private static readonly string logPath = "logs/tcp_server.log";
        private static readonly object lockObj = new object();

        static Logger()
        {
            Directory.CreateDirectory("logs");
        }

        public static void Log(string message)
        {
            lock (lockObj)
            {
                string logEntry = $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}] {message}\n";
                Console.Write(logEntry);
                File.AppendAllText(logPath, logEntry);
            }
        }
    }
}
